package com.mss.media.controller;


import com.mss.media.dto.AuditCaseDTO;
import com.mss.media.dto.PageDTO;
import com.mss.media.service.ICaseAuditListService;
import com.mss.media.util.ResultBody;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 审核列表 前端控制器
 * </p>
 *
 * @author runqiang
 * @since 2021-12-01
 */
@RestController
@RequestMapping("/case-audit-list")
@CrossOrigin
public class CaseAuditListController {

    @Autowired
    private ICaseAuditListService caseAuditListService;

    /**
     * 审核作品
     *
     * @param dto 审核信息
     * @param request 请求头
     * @return 状态
     */
    @RequiresPermissions("admin:case-audit")
    @PostMapping("/audit-case")
    public ResultBody auditCase(@RequestBody AuditCaseDTO dto, HttpServletRequest request) {
        return ResultBody.success(caseAuditListService.auditCase(dto,request));
    }

    /**
     * 查看审核分页
     *
     * @param dto 请求信息
     * @return 分页信息
     */
    @RequiresPermissions("admin:case-audit-find-allPage")
    @PostMapping("/find-allPage")
    public ResultBody findAuditCase(@RequestBody PageDTO dto) {
        return ResultBody.success(caseAuditListService.findAllPage(dto));
    }

    /**
     * 查看待审核作品信息
     *
     * @param caseId 作品ID
     * @return 信息
     */
    @RequiresPermissions("admin:case-audit-find-auditId")
    @GetMapping("/find-auditCase/{caseId}")
    public ResultBody findAuditCaseId(@PathVariable Long caseId) {
        return ResultBody.success(caseAuditListService.findAuditCaseId(caseId));
    }

}
